//
//  energyTableCell.m
//  cocoapodText
//
//  Created by apple on 16/9/9.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "ShiPei.h"
#import "energyTableCell.h"
#import <Foundation/Foundation.h>


@interface energyTableCell()
@property(nonatomic,strong) UILabel *conditionLabel;
@end

@implementation energyTableCell

//重写构造方法，让自定义的cell一创建出来就有四个子控件
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setFrame:[ShiPei CGRectMakeScale:0 :0 :TabChildContentW :35]];
        
        UIImageView *selectImageView=[[UIImageView alloc] initWithFrame:[ShiPei CGRectMakeScale:25 :35/4 :35/2 :35/2]];
        [self addSubview:selectImageView];
        [selectImageView setBackgroundColor:[UIColor whiteColor]];
        [selectImageView setImage:[UIImage imageNamed:@"login_check_box_0.png"]];
        self.selectImageView=selectImageView;
        
        UILabel *conditionLabel=[[UILabel alloc]initWithFrame:[ShiPei CGRectMakeScale:105/2 :0 :130 :35]];
        [self addSubview:conditionLabel];
        [conditionLabel setTextColor:FUIColorFromRGB(0x333333)];
        [conditionLabel setText:@""];
        [conditionLabel setFont:[UIFont boldSystemFontOfSize:[ShiPei CGFloatMakeFontScaleWithPX:26]]];
        self.conditionLabel=conditionLabel;
    }
    return self;
}

/**
 *  重写set方法
 *
 *  @param car
 */
-(void)setConditionInfo:(energyConditionInfo *)conditionInfo{
    //不要忘了，记录传递进来的模型
    _conditionInfo=conditionInfo;
    //给子控件赋值数据
    [self settingData];
}
/**
 *  对子控件的数据进行设置
 */
-(void)settingData{
    [self.conditionLabel setText:_conditionInfo.condition];
    if ([_conditionInfo.isOdd isEqualToString:@"1"]) {
        [self setBackgroundColor:FUIColorFromRGB(0xf2f8fd)];
    }else{
        [self setBackgroundColor:[UIColor whiteColor]];
    }
    if ([_conditionInfo.isSelect isEqualToString:@"1"]) {
        [self.selectImageView setImage:[UIImage imageNamed:@"login_check_box_1.png"]];
    }else{
        [self.selectImageView setImage:[UIImage imageNamed:@"login_check_box_0.png"]];
    }
}


@end

